package jt.classic.app.info;

import jt.classic.system.ISystemException;
import jt.classic.system.SimpleManager;
import jt.classic.system.user.IUser;

import org.limp.basework.SimpleBean;
import org.limp.basework.impl.SimpleBeanImpl;
import org.limp.basework.tools.BaseworkUtil;

import org.limp.mine.DateTrimmer;

import java.sql.Connection;


/**
 * 信息查看痕迹
 *
 * @author mido
 *
 */
public class InfoTraceManager extends SimpleManager {
    public InfoTraceManager(Connection conn) {
        super(conn);
    }

    /**
     * 记录信息浏览痕迹
     * @param id 主键ID
     * @param name 名称
     * @param type 类型
     * @param user 浏览用户
     * @param ip ip地址
     * @throws ISystemException
     */
    public void insert(String id, String name, String type, IUser user,
        String ip) throws ISystemException {
        BaseworkUtil util = new BaseworkUtil();
        SimpleBean sb = new SimpleBeanImpl();
        sb.getResource().put("oid", id);
        sb.getResource().put("oname", name);
        sb.getResource().put("otype", type);
        sb.getResource().put("oip", ip);
        sb.getResource().put("ouserid", user.id());
        sb.getResource().put("ousername", user.iname());
        sb.getResource().put("odate", DateTrimmer.getYMDHMS());

        try {
            util.manualSave("APP_INFO_ACCESSTRACE", sb, conn);
        } catch (Exception ex) {
            throw new ISystemException(ex);
        }
    }
}
